<?php

use swap\captcha;
use swap\visitor;
use swap\config;

class site_controller extends swap\controller {

	public static $layout = 'main';

	public static function index_action() {
		self::show_page();
	}
	
	public static function do_login_action() {
		
	}
	
	public static function test_action() {
		self::send_page();
	}
	
	public static function dev_action() {
		// captcha
		$text = '杨志兵啊';
		if (visitor::has_role('guest')) {
			visitor::set_role_var('guest', 'captcha', $text);
		} else {
			visitor::set_role('guest', 0, 0, array('captcha' => $text));
		}
		$captcha = visitor::get_role_var('guest', 'captcha');
		
		dump($captcha);
		
		captcha::set_text($text);
		captcha::set_noise_level(config::get('technique.captcha.noise_level', 1));
		captcha::set_font_file(swap\share_dir . '/font/simfang.ttf');
		captcha::set_size(150, 60);
		visitor::no_cache();
		visitor::set_role_var('guest', 'used', 0);
		$used = visitor::get_role_var('guest', 'used');
		dump($used);
		self::send(captcha::generate('zh'), 'image/png');
	}

}
